import pygame
import random
import easygui
from consts import *
from myclasses import *
background = pygame.image.load(image_background).convert()

pa = pygame.image.load(image_pa).convert_alpha()

enemy = pygame.image.load(image_enemy).convert_alpha()
enemy_2 = pygame.image.load(image_enemy_2).convert_alpha()
enemy_3 = pygame.image.load(image_enemy_3).convert_alpha()
enemy_4 = pygame.image.load(image_enemy_4).convert_alpha()
enemy_5 = pygame.image.load(image_enemy_5).convert_alpha()

player1 = pygame.image.load(image_player1).convert_alpha()
player2 = pygame.image.load(image_player2).convert_alpha()
player3 = pygame.image.load(image_player3).convert_alpha()
player4 = pygame.image.load(image_player4).convert_alpha()

enemy22 = pygame.image.load(image_enemy2_1).convert_alpha()
enemy2_1 = pygame.image.load(image_enemy2_2).convert_alpha()
enemy2_2 = pygame.image.load(image_enemy2_3).convert_alpha()
enemy2_3 = pygame.image.load(image_enemy2_4).convert_alpha()
enemy2_4 = pygame.image.load(image_enemy2_5).convert_alpha()
enemy2_5 = pygame.image.load(image_enemy2_6).convert_alpha()

gift = pygame.image.load(image_gift).convert_alpha()

max_pa = pygame.image.load(image_max_pa).convert_alpha()

loading1 = pygame.image.load(image_loading1).convert_alpha()
loading2 = pygame.image.load(image_loading2).convert_alpha()
loading3 = pygame.image.load(image_loading3).convert_alpha()

start_name = pygame.image.load(image_start_name).convert_alpha()

enemy_down_1 = []
enemy_down_1.extend([enemy_2, enemy_3, enemy_4, enemy_5])

enemy22_down = []
enemy22_down.extend([enemy2_1, enemy2_2, enemy2_3, enemy2_4, enemy2_5])

plane = []
plane.extend([player_plane1, player_plane2])
player = Player(plane[0], player_pos)
plane.extend([player1, player2, player3, player4])

loading = []
loading.extend([loading1, loading2, loading3])

enemy1_group = pygame.sprite.Group()
enemy1_group_down = pygame.sprite.Group()

enemy2_group = pygame.sprite.Group()
enemy2_group_down = pygame.sprite.Group()

gift_group = pygame.sprite.Group()
gift_down_group = pygame.sprite.Group()

player_group = pygame.sprite.Group()
player_group.add(player)

max_pa_group = pygame.sprite.Group()

back = Background(screen, background, 'dynamic')

time = 0

speed_1 = 30
speed_2 = 60

pa_speed = 10
easygui.msgbox(msg='经典飞机大战\n代码：于志翔\n素材：于志翔', title='游戏介绍', ok_button='开始游戏')

easygui.msgbox('小提示:' + '\n' + '按空格键可暂停' + '\n' + '开局有五秒无敌时间' + '\n' + '当分数大于5000时便可体验到本游戏最高难度')
easygui.msgbox('如果你能玩到一首歌结束，请联系作者，作者将会奖励你一个纸飞机(滑稽附体)')

run = True

time2 = 0

gift_num = 0

gift_bool = False

haha = False

level = 1

c_h = player_plane1.get_height()
c_w = player_plane1.get_width()

# 历史分数读入
with open(r'历史最高纪录.txt', "r") as f:
    date = f.read()
f.close()